on:
  push:
    paths:
      - 'docs/**'
      - 'data/templates/default/**'
name: Docs
env:
  extensions: mbstring, intl, iconv, libxml, dom, json, simplexml, zlib, fileinfo, gnupg
  key: cache-v1 # can be any string, change to clear the extension cache.
  defaultPHPVersion: '7.2'
  phiveGPGKeys: 4AA394086372C20A,D2CCAC42F6295E7D,E82B2FB314E9906E,8A03EA3B385DBAA1
  phiveHome: $GITHUB_WORKSPACE/.phive
jobs:
  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@master
        with:
          php-version: ${{ env.defaultPHPVersion }}
          extensions: ${{ env.extensions }}
          ini-values: memory_limit=2G, display_errors=On, error_reporting=-1
          tools: pecl

      - name: Install Composer dependencies
        run: |
          composer install --no-progress --prefer-dist --optimize-autoloader

      - name: Generate Documentation
        run: |
          ./bin/phpdoc --setting="guides.enabled=true" --force -v

      - name: Build Container
        uses: elgohr/Publish-Docker-Github-Action@master
        env:
          VERSION: '3.0'
        with:
          name: phpdocumentor/phpdocumentor/docs.phpdoc.org
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
          registry: docker.pkg.github.com
          context: docs
          buildargs: VERSION
          tags: '3.0'
        id: docs_build

      - name: 'deploy'
        uses: jaapio/keelsh-deploy@1.0.0
        with:
          keelBaseUrl: ${{ secrets.KEEL_BASE_URL }}
          image: 'docker.pkg.github.com/phpdocumentor/phpdocumentor/docs.phpdoc.org'
          tag: ${{ steps.docs_build.outputs.tag }}
